# -*- conding:utf-8 -*-
"""
请设计一个装饰器，它可以作用于任何函数上，打印函数执行时间：
import time
def metric(fn):
    start_time = time.time()
    end_time = time.time()

    print('耗时：{:.4f}s'.format(end_time - start_time))
    return fn

"""
import time


def warrp(fn):
    def metric(*args, **kwargs):
        start_time = time.time()
        fn(*args, **kwargs)
        # 执行函数
        end_time = time.time()
        print('耗时：{:.4f}s'.format(end_time - start_time))
        return fn
        # 返回函数的是地址
    return metric


@warrp
def func():
    with open('./a.txt', 'w') as f1:
        f1.write(func.__name__)
        print('写入日志成功，函数名字是:%s' % func.__name__)



func()
